const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
//导入路由
const homeRouter = require('./routes/home');
const indexRouter = require('./routes/index');
const uploadRouter = require('./routes/upload');

const app = express();
//设置post请求的参数解析
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
//views的路径
app.set('views',path.join(__dirname, 'views'));
//静态资源访问路径
app.use('/static', express.static(path.join(__dirname, 'public')))
//使用路由中间件
app.use(homeRouter);
app.use(indexRouter);
app.use(uploadRouter);
//使用模板引擎
app.set('view engine', 'ejs');
app.listen(3000, () => {
  console.log('启动了3000');
})